#include "stdafx.h"
#include "Detail.h"

extern DuiLib::CContainerUI* g_pBody;

DetailDlg::DetailDlg(DuiLib::CPaintManagerUI& pm ):m_pm(pm)
{

}

bool DetailDlg::ShowDetail(LPCTSTR strText)
{
	DuiLib::CDialogBuilder cb;
	m_pRoot = cb.Create(_T("DetailDlg.xml"), 0, NULL, &m_pm);
	DuiLib::CControlUI* pClose = m_pm.FindSubControlByName(m_pRoot, _T("btnclose"));
	pClose->OnNotify += DuiLib::MakeDelegate(this, &DetailDlg::OnClose);
	DuiLib::CControlUI* pText = m_pm.FindSubControlByName(m_pRoot, _T("text"));
	pText->SetText(strText);
	g_pBody->Add(m_pRoot);

	return true;
}

bool DetailDlg::OnClose(void* param)
{
	DuiLib::TNotifyUI* msg = (DuiLib::TNotifyUI*)param;
	if(msg->sType == _T("click"))
	{
		g_pBody->Remove(m_pRoot);
	}
	return true;
}
